package com.mechat.webview

import android.graphics.Bitmap
import android.net.Uri
import android.os.Message
import android.view.View
import android.webkit.*
import android.webkit.WebChromeClient.CustomViewCallback
import android.webkit.WebStorage.QuotaUpdater

abstract class WebChromeClientListener {
    fun openFileChooser(
        uploadFile: ValueCallback<Uri?>?,
        acceptType: String?,
        capture: String?
    ) {
    }

    fun onProgressChanged(view: WebView?, newProgress: Int) {}
    fun onReceivedTitle(view: WebView?, title: String?) {}
    fun onReceivedIcon(view: WebView?, icon: Bitmap?) {}
    fun onReceivedTouchIconUrl(
        view: WebView?,
        url: String?,
        precomposed: Boolean
    ) {
    }

    fun onShowCustomView(view: View?, callback: CustomViewCallback?) {}
    fun onShowCustomView(
        view: View?,
        requestedOrientation: Int,
        callback: CustomViewCallback?
    ) {
    }

    fun onHideCustomView() {}
    fun onCreateWindow(
        view: WebView?,
        isDialog: Boolean,
        isUserGesture: Boolean,
        resultMsg: Message?
    ): Boolean {
        return false
    }

    fun onRequestFocus(view: WebView?) {}
    fun onCloseWindow(window: WebView?) {}
    fun onJsAlert(
        view: WebView?,
        url: String?,
        message: String?,
        result: JsResult?
    ): Boolean {
        return false
    }

    fun onJsConfirm(
        view: WebView?,
        url: String?,
        message: String?,
        result: JsResult?
    ): Boolean {
        return false
    }

    fun onJsPrompt(
        view: WebView?,
        url: String?,
        message: String?,
        defaultValue: String?,
        result: JsPromptResult?
    ): Boolean {
        return false
    }

    fun onJsBeforeUnload(
        view: WebView?,
        url: String?,
        message: String?,
        result: JsResult?
    ): Boolean {
        return false
    }

    fun onGeolocationPermissionsShowPrompt(
        origin: String?,
        callback: GeolocationPermissions.Callback?
    ) {
    }

    fun onGeolocationPermissionsHidePrompt() {}
    fun onJsTimeout(): Boolean {
        return true
    }

    fun onConsoleMessage(message: String?, lineNumber: Int, sourceID: String?) {}
    fun onConsoleMessage(consoleMessage: ConsoleMessage?): Boolean {
        return false
    }

    val defaultVideoPoster: Bitmap?
        get() = null

    val videoLoadingProgressView: View?
        get() = null

    fun getVisitedHistory(callback: ValueCallback<Array<String>>?) {}
    fun onExceededDatabaseQuota(
        url: String?,
        databaseIdentifier: String?,
        quota: Long,
        estimatedDatabaseSize: Long,
        totalQuota: Long,
        quotaUpdater: QuotaUpdater?
    ) {
    }

    fun onReachedMaxAppCacheSize(
        requiredStorage: Long,
        quota: Long,
        quotaUpdater: QuotaUpdater?
    ) {
    }
}